let utils = data["utils"];
let STUtil = data["STUtil"];
let Node = data["Node"];
let SplayTree = data["SplayTree"];
let isInBbox = data["isInBbox"];
let getBboxOverlap = data["getBboxOverlap"];
let cmp = data["cmp"];
let crossProduct = data["crossProduct"];
let dotProduct = data["dotProduct"];
let compareVectorAngles = data["compareVectorAngles"];
let sineOfAngle = data["sineOfAngle"];
let cosineOfAngle = data["cosineOfAngle"];
let closestPoint = data["closestPoint"];
let horizontalIntersection = data["horizontalIntersection"];
let verticalIntersection = data["verticalIntersection"];
let intersection = data["intersection"];
let perpendicular = data["perpendicular"];
let rounder = data["rounder"];
let geomIn = data["geomIn"];
let geomOut = data["geomOut"];
let operation = data["operation"];
let Segment = data["Segment"];
let SweepEvent = data["SweepEvent"];
let SweepLine = data["SweepLine"];
console.log("12PolygonClipping_segment02");

utils.extend(Segment.prototype, {
  split: function (point) {
    const newEvents = [],
      alreadyLinked = void 0 !== point.events,
      newLeftSE = new SweepEvent(point, !0),
      newRightSE = new SweepEvent(point, !1),
      oldRightSE = this.rightSE;
    this.replaceRightSE(newRightSE), newEvents.push(newRightSE), newEvents.push(newLeftSE);
    const newSeg = new Segment(newLeftSE, oldRightSE, this.rings.slice(), this.windings.slice());
    return SweepEvent.comparePoints(newSeg.leftSE.point, newSeg.rightSE.point) > 0 && newSeg.swapEvents(), SweepEvent.comparePoints(this.leftSE.point, this.rightSE.point) > 0 && this.swapEvents(), alreadyLinked && (newLeftSE.checkForConsuming(), newRightSE.checkForConsuming()), newEvents
  },
  swapEvents: function () {
    const tmpEvt = this.rightSE;
    this.rightSE = this.leftSE, this.leftSE = tmpEvt, this.leftSE.isLeft = !0, this.rightSE.isLeft = !1;
    for (let i = 0, iMax = this.windings.length; i < iMax; i++) this.windings[i] *= -1
  },
  consume: function (other) {
    let consumer = this,
      consumee = other;
    for (; consumer.consumedBy;) consumer = consumer.consumedBy;
    for (; consumee.consumedBy;) consumee = consumee.consumedBy;
    const cmp = Segment.compare(consumer, consumee);
    if (0 !== cmp) {
      if (cmp > 0) {
        const tmp = consumer;
        consumer = consumee, consumee = tmp
      }
      if (consumer.prev === consumee) {
        const tmp = consumer;
        consumer = consumee, consumee = tmp
      }
      for (let i = 0, iMax = consumee.rings.length; i < iMax; i++) {
        const ring = consumee.rings[i],
          winding = consumee.windings[i],
          index = consumer.rings.indexOf(ring); - 1 === index ? (consumer.rings.push(ring), consumer.windings.push(winding)) : consumer.windings[index] += winding
      }
      consumee.rings = null, consumee.windings = null, consumee.consumedBy = consumer, consumee.leftSE.consumedBy = consumer.leftSE, consumee.rightSE.consumedBy = consumer.rightSE
    }
  }
});



return {
  "utils": utils,
  "STUtil": STUtil,
  "Node": Node,
  "SplayTree": SplayTree,
  "isInBbox": isInBbox,
  "getBboxOverlap": getBboxOverlap,
  "cmp": cmp,
  "crossProduct": crossProduct,
  "dotProduct": dotProduct,
  "compareVectorAngles": compareVectorAngles,
  // "length":length,
  "sineOfAngle": sineOfAngle,
  "cosineOfAngle": cosineOfAngle,
  "closestPoint": closestPoint,
  "horizontalIntersection": horizontalIntersection,
  "verticalIntersection": verticalIntersection,
  "intersection": intersection,
  "perpendicular": perpendicular,
  "rounder": rounder,
  "geomIn": geomIn,
  "geomOut": geomOut,
  "operation": operation,
  "Segment": Segment,
  "SweepEvent": SweepEvent,
  "SweepLine": SweepLine
}